
import java.util.Scanner;

class SALDO13 {

    static Scanner entrada = new Scanner(System.in);

    public static void main(String[] args) {

        int N = entrada.nextInt();
        int S = entrada.nextInt();
        int menor = S;
        for (int i = 0; i < N; i++) {
            S += entrada.nextInt();
            if (menor > S) {
                menor = S;
            }
        }
        System.out.println(menor);
    }

}
